package com.globalresources.business.impl;

import java.util.List;
import org.springframework.transaction.annotation.Transactional;
import com.globalresources.business.inface.IAuthorityService;
import com.globalresources.dao.inface.IAuthorityDao;
import com.globalresources.dao.inface.IRelationDao;
import com.globalresources.po.Authority;


/**
 * @author aaron.lu(luzhiyuan) E-mail:atyuan.lu@gmail.com
 * @since 创建时间：Jul 7, 2009 3:12:31 AM
 */


public class AuthorityServiceImpl implements IAuthorityService {
	private IAuthorityDao authorityDao;
	private IRelationDao relationDao;

	public void setRelationDao(IRelationDao relationDao) {
		this.relationDao = relationDao;
	}

	public void setAuthorityDao(IAuthorityDao authorityDao) {
		this.authorityDao = authorityDao;
	}
	
	/**
	 * load authority
	*@author aaron.lu(luzhiyuan)
	*@param authority
	*@param pagesize
	*@param startrow
	*@return
	 */
	public List<Authority> getAuthorities(String authority, int pagesize, int startrow){
		return authorityDao.getAuthorities(authority, pagesize, startrow);
	}
	
	/**
	 * count authorities
	*@author aaron.lu(luzhiyuan)
	*@param authority
	*@return
	 */
	public int countAuthorities(String authority){
		return authorityDao.count(authority);
	}
	
	/**
	 * load a authority by id
	*@author aaron.lu(luzhiyuan)
	*@param id
	*@return
	 */
	public Authority getAuthority(Integer id){
		return authorityDao.find(id);
	}
	
	/**
	 * save a authority
	*@author aaron.lu(luzhiyuan)
	*@param authority
	 */
	public void saveAuthority(Authority authority){
		authorityDao.save(authority);
	}
	
	/**
	 * update a authority
	*@author aaron.lu(luzhiyuan)
	*@param authority
	 */
	public void updateAuthority(Authority authority){
		authorityDao.save(authority);
	}
	
	/**
	 * delete a authority
	*@author aaron.lu(luzhiyuan)
	*@param authority
	 */
	public void deleteAuthority(Authority authority){
		authorityDao.remove(authority);
	}
	
	/**
	 * List Authority
	*@author songduanlei@gmail.com
	*@param null
	 */
	public List<Authority> listAuthority(){
		return authorityDao.findAll();
	}
}
